package benny_driving_ser.util;

import java.text.Format;

/**
 * 计费逻辑
 * @author Administrator
 *
 */
public class CalcDrivingCostUtil {
	
	/**
	 * 
	 * @param daytime 日计=0，夜计=1
	 * @param mil   公里数
	 * @return 优惠金额
	 * @throws Exception daytime检测
	 */
	public static int getTaximeterPrivilege(int daytime, int mil) throws Exception {
		
		int hour = Integer.parseInt(FormatUtil.getTimeFormat(System.currentTimeMillis()).split(" ")[1].split(":")[0]);
//		System.out.println("hour"+hour);
		
		switch (daytime) {
		case 0:
			if (mil < 4)
				return 15;
			if (mil < 11)
				return 15 + (mil - 3) * 2;
			return 15 + 14 + (mil - 10) * 4;
		case 1:
			if (mil < 4)
				return 15;
			if (mil < 11)
				return 15 + (mil - 3) * 4;
			return 15 + 28 + (mil - 10) * 6;
		case 2:
			if (mil < 4)
				return 15;
			if(hour>=22 || hour<8){
				if (mil < 11 )
					return 15 + (mil - 3) * 4;
				return 15 + 28 + (mil - 10) * 6;
			}else{
				if (mil < 4)
					return 15;
				if (mil < 11)
					return 15 + (mil - 3) * 2;
				return 15 + 14 + (mil - 10) * 4;
			}
		default:
			throw new Exception("no such daytime");
		}
	}
	
	public static int getWaitCost(int time){
		if(time>5){
			return time-5;
		}else{
			return 0;
		}
		
	}
	
	public static void main(String[] args) throws Exception {
		System.out.println(getTaximeterPrivilege(1,32));
		
//		String time = FormatUtil.getTimeFormat(System.currentTimeMillis());
//		System.out.println(time);
//		time = time.split("");
		
	}
	
}
